\section*{\large Design}
\begin{normalsize}


Our program consists of three nodes: robot, navigation and map. They communicate with each other via the request-reply pattern based on the following services:

\begin{itemize}
\item \textbf{move\_to\_cell}: it is exposed by robot and requested by navigation, receives an integer in the range [0, 3], makes the robot move to the north (0), east(1), south(2) or west(3) cell and finally returns true if successful, or false otherwise;
\item \textbf{get\_neighbors}: it is exposed by robot and requested by navigation, makes the robot look for obstacles in its von Neumann neighbourhood and returns a boolean vector of size four. Each vector entry is zero if free, or one otherwise;
\item \textbf{send\_updated\_map}: it is exposed by navigation and requested by map, returns the map with the robot position.
\end{itemize}

Figure \ref{services} shows the client-server relations. The robot node can be thought of as the actuator and the navigation node as the brain. The robot knowledge of the world is displayed by the map node step by step.

\begin{figure}[!htb]
\centering
\includegraphics[width=\textwidth,trim=0cm 10cm 0cm 1cm, clip=true]{./images/lab2services.pdf}
\caption{client-server relations}
\label{services}
\end{figure}

The publish/subscribe model is a very flexible communication paradigm, but its many-to-many one-way transport is not appropriate for RPC request/reply interactions. Not only using services instead of topics keeps the application architecture very simple but also enables higher performances because of the efficient bandwidth utilization, for example the navigation node does not need to ``busy wait'' for the robot responses.

The following three sections provide a deep insight into the functionalities of each node: besides describing each function, in the first particular attention is paid to describe how sensors are exploited and in the second an algorithm overview is given, the generalization from static map (known obstacles) to dynamic (unknown moving obstacles) and the usefulness of the emulation functions are also pointed out.


\end{normalsize}